#pragma once

#include <AVUITimeline.h>

namespace AVUI {

class TimelineCollection;
class ClockGroup;

class TimelineGroup : public Timeline
{
public:
    DECLARE_ELEMENT(TimelineGroup, Timeline);

    DECLARE_DEPENDENCY_PROPERTY_BEGIN(Children);
        DECLARE_ATTRIBUTE_CONTENTPROPERTY();
        DECLARE_ATTRIBUTE_AUTOCREATE();
    DECLARE_DEPENDENCY_PROPERTY_END();
    TRefCountedPtr<TimelineCollection> get_Children() { return (TimelineCollection*)(Object*)GetValue(get_ChildrenProperty()); }
    void set_Children(TimelineCollection* pValue) { SetValue(get_ChildrenProperty(), (Object*)pValue); } 

    TimelineGroup() : Timeline() { }
    TimelineGroup(const Nullable<TimeSpan>& beginTime) : Timeline(beginTime) { }
    TimelineGroup(const Nullable<TimeSpan>& beginTime, const Duration& duration) : Timeline(beginTime, duration) { }
    TimelineGroup(const Nullable<TimeSpan>& beginTime, const Duration& duration, const RepeatBehavior& repeatBehavior) : Timeline(beginTime, duration, repeatBehavior) { }

    TRefCountedPtr<ClockGroup> CreateClock();
    virtual TRefCountedPtr<Clock> AllocateClock();

private:
    static void StaticConstructor();    

};

  
class ParallelTimeline : public TimelineGroup
{
public:
    DECLARE_ELEMENT(ParallelTimeline, TimelineGroup);

    DECLARE_DEPENDENCY_PROPERTY(SlipBehavior);
    SlipBehavior::Enum get_SlipBehavior() { return (SlipBehavior::Enum)(AVUI::UnboxValue<int>(GetValue(get_SlipBehaviorProperty()))); }
    void set_SlipBehavior(SlipBehavior::Enum value) { SetValue(get_SlipBehaviorProperty(), AVUI::BoxValue<int>(value)); } 

    ParallelTimeline() : TimelineGroup() { }
    ParallelTimeline(const Nullable<TimeSpan>& beginTime) : TimelineGroup(beginTime) { }
    ParallelTimeline(const Nullable<TimeSpan>& beginTime, const Duration& duration) : TimelineGroup(beginTime, duration) { }
    ParallelTimeline(const Nullable<TimeSpan>& beginTime, const Duration& duration, const RepeatBehavior& repeatBehavior) : TimelineGroup(beginTime, duration, repeatBehavior) { }

protected:

    virtual Duration get_NaturalDurationCore(const Clock* pClock);
    virtual TRefCountedPtr<Freezable> CreateInstanceCore() AVUI_OVERRIDE { return object_allocate<ParallelTimeline>().get_Ptr(); }

private:
    static void StaticConstructor();    

};

}; // namespace AVUI
